package com.yh.workbill.ui.me.mvp;

import com.yh.workbill.model.WorkBillCount;

import androidx.lifecycle.Lifecycle;
import androidx.lifecycle.LifecycleObserver;
import androidx.lifecycle.OnLifecycleEvent;

public class Me_Presenter implements LifecycleObserver {
    private Me_View view;
    private Me_Model model;

    public Me_Presenter(Me_View view) {
        this.view = view;
        this.model = new Me_Model();
    }

    public void getUserPhone() {
        model.getUserInfo(new Me_Model.UserInfoCallBack() {
            @Override
            public void onSuccess(String phone) {
                view.displayUserPhone(phone);
            }
        });
    }


    public void getWorkBillCount() {
        model.getWorkBillCount(new Me_Model.WorkBillCountCallback() {
            @Override
            public void onSuccess(WorkBillCount data) {
                view.getWorkBillCountInfo(data);
            }
        });
    }

    @OnLifecycleEvent(Lifecycle.Event.ON_DESTROY)
    public void onDestory() {
        if (this.view == null) {
            this.view = null;
        }
    }

}
